<!DOCTYPE html>
<html  xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{https://www.makeapie.cn/dep/echarts/map/js/china.js}"></script>
    <script th:src="@{https://oisanjavax.github.io/echarts-wordcloud/dist/echarts-wordcloud.min.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/layui/layui.js}"></script>
</head>
<body class="childrenBody">
<!-- layui公共模块-->

<div >

    <div class="layui-bg-gray" style="padding: 30px;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="layui-panel">
                    实时数据展示
                    <div id="ciyun" style= "width:700px;height:200px;"></div>
                    <div style="margin-left: 100px;padding-top: 5px">
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                            <legend th:text="'实时疫情数据----截止至'+${updateTime}">实时疫情数据</legend>
                        </fieldset>

                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-danger" th:text="'确诊人数'+${ChinaTotal?.confirm}">警告按钮</button>
                            <button type="button" class="layui-btn" th:text="'治愈人数'+${ChinaTotal?.heal}">默认按钮</button>
                            <button type="button" class="layui-btn layui-btn-normal" th:text="'境外输入'+${ChinaTotal?.input}">百搭按钮</button>
                            <button type="button" class="layui-btn layui-btn-primary" th:text="'死亡人数'+${ChinaTotal?.dead}">原始按钮</button>

                        </div>
                    </div>
                    中国疫情地图
                    <div id="main" style= "width: 700px;height:600px;"></div>
                </div>
            </div>
            <div class="layui-col-md4">
                <div style="padding-top: 10px">
                <div class="layui-panel">
                    <div class="layui-carousel" id="test1" lay-filter="test1">
                        <div carousel-item="">
                            <div><img style="height: 100%;width: 100%" th:src="@{/images/banner3.jpg}"></div>
                            <div><img style="height: 100%;width: 100%" th:src="@{/images/banner2.jpg}"></div>
                            <div><img style="height: 100%;width: 100%" th:src="@{/images/banner1.jpg}"></div>
                        </div>
                    </div>

                    <!--新闻数据-->
                    <div  style="padding-top: 10px">
                        <ul class="layui-timeline">

                            <li  th:each="n : ${newsList}" class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <h3 class="layui-timeline-title" th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:ss')}">8月18日</h3>
                                    <p>
                                        <br><span class="layui-badge layui-bg-orange">标题:</span><span th:text="${n.title}"></span>
                                        <br><span class="layui-badge layui-bg-green">内容:</span><span th:text="${n.content}"></span>
<!--                                        <br><span class="layui-badge layui-bg-blue">图片:</span><span th:text="${n.pic}"></span>-->
                                        <br><img th:src="${n.pic}"style="height: 100px;width: 100px">
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>

                </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script>
    //JS
    layui.use(['carousel','element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,carousel = layui.carousel
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });
        //轮播图
        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'always'
            ,height:'220px'
            ,width:'350px'
        });

    });
</script>

<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    var dataList = [];
    option = {
        tooltip: {
            triggerOn: "click",
            formatter: function(e, t, n) {
                return '.5' == e.value ? e.name + "：有疑似病例" : e.seriesName + "<br />" + e.name + "：" + e.value
            }
        },
        toolbox: {
            show: true,
            orient: 'vertical',
            left: 'right',
            top: 'center',
            feature: {
                dataView: {readOnly: false},
                restore: {},
                saveAsImage: {}
            }
        }, // 提供下载工具
        visualMap: {
            min: 0,
            max: 100000,
            left: 26,
            bottom: 40,
            showLabel: !0,
            text: ["高", "低"],
            pieces: [{
                gt: 10000,
                label: "> 10000人",
                color: "#7f1100"
            }, {
                gte: 1000,
                lte: 10000,
                label: "1000 - 10000人",
                color: "#ff5428"
            }, {
                gte: 100,
                lt: 1000,
                label: "100 - 1000人",
                color: "#ff8c71"
            }, {
                gt: 10,
                lt: 100,
                label: "10 - 100人",
                color: "#ffd768"
            }, {
                gt: 1,
                lt: 10,
                label: "1 - 10人",
                color: "#ffffff"
            }],
            show: !0
        },
        geo: {
            map: "china",
            roam: !1,
            scaleLimit: {
                min: 1,
                max: 2
            },
            zoom: 1.23,
            top: 120,
            label: {
                normal: {
                    show: !0,
                    fontSize: "14",
                    color: "rgba(0,0,0,0.7)"
                }
            },
            itemStyle: {
                normal: {
                    //shadowBlur: 50,
                    //shadowColor: 'rgba(0, 0, 0, 0.2)',
                    borderColor: "rgba(0, 0, 0, 0.2)"
                },
                emphasis: {
                    areaColor: "#f2d5ad",
                    shadowOffsetX: 0,
                    shadowOffsetY: 0,
                    borderWidth: 0
                }
            }
        }
    };

    $.ajax({
        url:'/index/query',
        dataType:"json",
        success:function (data){
            for (let i in data) {
                dataList[i] = data[i];
            }myChart.setOption({
                series: [{
                    name: "确诊病例",
                    type: "map",
                    geoIndex: 0,
                    data: dataList
                }]
            })
        }
    })

    myChart.setOption(option);
</script>
<script type="text/javascript">
    var Chart = echarts.init(document.getElementById('ciyun'));
    var hotlist = [];

    var wordcloud_car_color =["#60ACFC", "#61D7D3", "#AEE498", "#32D3EB", "#999999"];

    ciyunoption = {

        title:{
            show: true,
            text: "微博热搜",
            textStyle: {
                color: '#666666',
                fontSize: 14
            }
        },
        tooltip:{
            trigger: "item"
        },
        toolbox: {
            show: true,
            feature: {
                dataView: {
                    show: true
                },
                restore: {
                    show: true
                }
            }
        },
    };

    $.ajax({
        url: "/index/ciyun",
        dataType: "json",
        success:function (data){
            for (let i in data){
                hotlist[i] = data[i];
            }Chart.setOption({
                series: [ {
                    type: 'wordCloud',
                    sizeRange: [10, 80],
                    rotationRange: [-90, 90],
                    rotationStep: 90,
                    gridSize: 2,

                    // The shape of the "cloud" to draw. Can be any polar equation represented as a
                    // callback function, or a keyword present. Available presents are circle (default),
                    // cardioid (apple or heart shape curve, the most known polar equation), diamond (
                    // alias of square), triangle-forward, triangle, (alias of triangle-upright, pentagon, and star.
                    shape: 'square',

                    //maskImage: maskImage,
                    left: 'center',
                    top: 'center',
                    //width: '60%',
                    //height: '80%',
                    //right: null,
                    //bottom: null,
                    drawOutOfBound: false,
                    textStyle: {
                        normal: {
                            //color: '#60ACFC',
                            color: function () {
                                // 随机从颜色序列中取色
                                var index = Math.floor((Math.random()*wordcloud_car_color.length));
                                //console.log('index:'+index);
                                //console.log('colorOrder:'+colorOrder[index]);
                                return wordcloud_car_color[index];
                            }
                        },
                        emphasis: {
                            color: '#60ACFC',
                            shadowBlur: 6,
                            shadowColor: '#dddddd'
                        }
                    },
                    data: hotlist.sort(function (a, b) {
                        return b.value  - a.value;
                    })
                } ]
            })
        }
    })
    Chart.setOption(ciyunoption);
</script>
</body>
</html>